using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Microsoft.Practices.RepositoryFactory.CustomPages.UI
{
    internal class ListBoxEx : ListBox
    {
        int index = -1;

        protected override void OnSelectedIndexChanged(EventArgs e)
        {
            if(this.SelectionMode == SelectionMode.One)
            {
                if(this.SelectedIndex != -1)
                {
                    if(this.SelectedIndex == index)
                    {
                        index = -1;
                        this.SelectedIndex = index;
                    }
                    else
                    {
                        index = this.SelectedIndex;
                    }

                    base.OnSelectedIndexChanged(e);
                }
            }
            else
            {
                base.OnSelectedIndexChanged(e);
            }
        }
    }
}
